Linux下 mysql卸载与远程访问

作者 江辉 日期 2016-02-03
Linux下 mysql卸载与远程访问

标签: Linux
1.删除 mysql

sudo apt-get autoremove --purge mysql-server-5.5
sudo apt-get remove mysql-server
sudo apt-get autoremove mysql-server
sudo apt-get remove mysql-common (非常重要)

上面的其实有一些是多余的,建议还是按照顺序执行一遍

2.清理残留数据

dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P

##安装

sudo apt-get install mysql-server

##检查是否安装成功

root@gotyenj-virtual-machine:/# mysql -u root -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 42
Server version: 5.5.44-0ubuntu0.14.04.1 (Ubuntu)
mysql> 

这样表示安装成功

##远程访问

本来以为这样安装就能正常访问了,但是这样还是不能通过navicat >访问mysql。会出现如下错误2003-Can’t connect to MySQL on ’192.168.1.2’(10061)
通过修改/etc/mysql/my.cnf 来解决
修改如下 bind-address=127.0.0.1 为 bind-address=0.0.0.0


重新启动mysql,重新用navicat访问发现如下错误
1045-Access denied for user root@IT(using password:NO)
这表明需要修改权限


登录mysql

mysql> grant all on *.* to 用户名@"%" identified by "密码";

这样就能正常访问了。